/*
 * AnalyzeCharges.h
 *
 *  Created on: May 26, 2011
 *      Author: marchi
 */

#ifndef ANALYZECHARGES_H_
#define ANALYZECHARGES_H_

#include "Metric.h"
#include <cstdlib>
#include <cstdio>
#include "time.h"
#include "pdbio.h"
#include "confio.h"
#include "CellSymmetry.h"
#include "ResidueCM.h"
#include "ResidueAvg.h"

#include "ForceConst.h"

//enum ElecType {Slt, Sol, Tot};


static int nframes=0;

static CellSymmetry * symmetry=NULL;
static ResidueCM * Res=NULL;

static int Analyze(t_topology *top, t_trxframe *fr, t_pbc *pbc,
              int nr, gmx_ana_selection_t *sel[], void *data)
{
	ResidueAvg * Avgs0=static_cast<ResidueAvg *> (data);
	ResidueAvg & Avgs=*Avgs0;
    /* Here, you can do whatever analysis your program requires for a frame. */
    srand (time(NULL) );

    if(!Res) {
    	Res=new ResidueCM;
    	Res->Allocate();
    }

    if(!symmetry) symmetry=new CellSymmetry(top,fr,pbc);

    Metric Met;
    Met(fr->box);
    symmetry->Center();
    symmetry->Fit();
    (*Res)(fr->x);
    Avgs+=(*Res);
    nframes++;
    return 0;
}

#endif /* ANALYZECHARGES_H_ */
